home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 671 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: harinath@cs.umn.edu (Raja R Harinath)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: possible extension -- typeof(expr)
  5. Date: 08 Mar 1996 16:06:31 PST
  6. Organization: Dept of Comp Sc, Univ of Minnesota
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <d93f7jp4d6.fsf@hecto.cs.umn.edu>
  9. References: <199603061757.AA17403@zacatecas.optimum.com>
  10.     <u9ag1t3njg.fsf@yorick.cygnus.com>
  11. NNTP-Posting-Host: isolde.mti.sgi.com
  12. Mime-Version: 1.0 (generated by tm-edit 7.46)
  13. X-Original-Date: 08 Mar 1996 17:11:33 -0600
  14. X-Newsreader: September Gnus v0.50/Emacs 19.30
  15. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  16.     iQBVAwUBMUDLpEy4NqrwXLNJAQH3JwIAsgxqz2iiYrhBBLrQk5JC26Q5+dZ+tRNg
  17.     ++Hp5XWAtBlesYLLl/r9gKpzYghDp+h+swE5ep5VvOjizf2vcciHsw==
  18.     =Yyqv
  19. Originator: austern@isolde.mti.sgi.com
  20.  
  21. In article <u9ag1t3njg.fsf@yorick.cygnus.com> 
  22. jason@cygnus.com (Jason Merrill) writes:
  23. > >>>>> Tim Boemker <tjb839@zacatecas.optimum.com> writes:
  24. > > Many times in working with STL I've wished for a new operator to return
  25. > > the type of an expression, much the same way sizeof returns the size of
  26. > > an expression.
  27. > > It would allow programs like the following, for example:
  28. > >    set<foo, less<foo> > s;
  29. > >    for(typeof(s)::iterator i = s.begin(); i != s.end(); i++)
  30. > >       // do something
  31. > > I suppose this must have been considered by now.  Has anything come of
  32. > > it?
  33. > It has come up in the committee, but no-one has made a formal proposal, and
  34. > it's too late now.
  35.  
  36. Instead of introducing a new keyword `typeof', what about allowing this
  37. usage:
  38.  
  39.   set <foo, less<foo> > s;
  40.   for (typename s.iterator i = s.begin(); ... )
  41.        ^^^^^^^^ ^^^
  42.        |        |
  43.       (1)      (2)
  44.  
  45. 1. Extending `typename' to a non-template context to allow (2).
  46.  
  47. 2. Accessing a member type/typedef using the `.' syntax (and against an
  48.    object) instead of the `::' syntax against a typename.
  49.  
  50. (1) above solves the parsing problem associated with allowing syntax (2)
  51. independently, and uses an existing keyword (and extends its meaning,
  52. without, IMO, overloading it).
  53.  
  54. - Hari
  55. ---
  56. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  57.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  58.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  59.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  60.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  61. ]
  62.